package cc.sheji.util;

import java.util.Random;

/**
 * 随机数生成
 *
 */
public class RandomUtil {

    private static String[] SEED={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
            "1","2","3","4","5","6","7","8","9","0",
            "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};

    /**
     * 根据传入长度或取随机数
     * @param len
     * @return
     */
    public static String getRandomString(int len){
        if(len<1)
            return null;
        StringBuilder sb=new StringBuilder();
        for (int i = 0; i < len; i++) {
            int random=new Random().nextInt(62);
            sb.append(SEED[random]);
        }
        return sb.toString();
    }

}
